//
//  HYMeetingRoomInfoView.m
//  Booking
//
//  Created by Maybe_文仔 on 2018/7/27.
//  Copyright © 2018年 Duntech. All rights reserved.
//

#import "HYSeatInfoView.h"

@interface HYSeatInfoView()
@property (nonatomic, strong) UILabel *seatLab;
@property (nonatomic, strong) UILabel *addressLab;
@property (nonatomic, strong) UIButton *bookingBtn;
@end

@implementation HYSeatInfoView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [KAPP_WHITE_COLOR colorWithAlphaComponent:0.8];
        [self setupSubViews];
    }
    return self;
}

-(void)setupSubViews{
    [self addSubview:self.seatLab];
    [self addSubview:self.addressLab];
    [self addSubview:self.bookingBtn];
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    [self.seatLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(16*WIDTH_MULTIPLE);
        make.left.equalTo(self.mas_left).offset(10*WIDTH_MULTIPLE);
    }];
    
    [self.addressLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.seatLab.mas_bottom).offset(12*WIDTH_MULTIPLE);
        make.left.equalTo(self.seatLab.mas_left);
    }];
    
    [self.bookingBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.mas_centerY);
        make.right.equalTo(self.mas_right).offset(-10*WIDTH_MULTIPLE);
        make.size.mas_equalTo(CGSizeMake(68*WIDTH_MULTIPLE, 34*WIDTH_MULTIPLE));
    }];
}

-(void)setSeatModel:(HYSeatCellModel *)seatModel{
    _seatModel = seatModel;
    self.seatLab.text = [NSString stringWithFormat:@"%@：%@",NSLocalizedString(@"seatNo", nil),seatModel.name];
    self.addressLab.text = [NSString stringWithFormat:@"%@ %@ %@",seatModel.cityName,seatModel.buildName,seatModel.floorName];
}

-(void)bookAction{
    if (self.bookSeatBlock) {
        self.bookSeatBlock(self.seatModel);
    }
}

#pragma mark - lazyload

-(UILabel *)seatLab{
    if (!_seatLab) {
        _seatLab = [[UILabel alloc]init];
        _seatLab.textColor = KAPP_THEME_COLOR;
        _seatLab.font = KFitFont(20);
        _seatLab.text = NSLocalizedString(@"seatNo", nil);
    }
    return _seatLab;
}

-(UILabel *)addressLab{
    if (!_addressLab) {
        _addressLab = [[UILabel alloc]init];
        _addressLab.textColor = RGBColor(51, 51, 51);
        _addressLab.font = KFitFont(17);
    }
    return _addressLab;
}

-(UIButton *)bookingBtn{
    if (!_bookingBtn) {
        _bookingBtn = [[UIButton alloc]init];
        [_bookingBtn setTitle:NSLocalizedString(@"book", nil) forState:(UIControlStateNormal)];
        _bookingBtn.titleLabel.textColor = KAPP_WHITE_COLOR;
        _bookingBtn.backgroundColor = KAPP_THEME_COLOR;
        _bookingBtn.titleLabel.font = KFitFont(18);
        _bookingBtn.layerCornerRadius = 5.0;
        [_bookingBtn addTarget:self action:@selector(bookAction) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _bookingBtn;
}


@end
